<?php 
include('class/conmssql.php');
include('class/function.php');

		$userlogin = $_REQUEST['username'];
		$passlogin = $_REQUEST['password'];
		$queryrow = msssqlselectdata("*","[dbo].[Usernames]","sUserName = '$userlogin'");
		$rowq = mssql_num_rows($queryrow);
		//echo $rowq;
		if ( $rowq == 0)
		{
			
			$_SESSION['code_errorlogin'] = " Usernames Fail";
			
			}else{
			
			$loginquery = mssql_fetch_array($queryrow);
			
			$querypass = msssqlselectdata("*","[dbo].[UserDetail]","pkUser = '$loginquery[pkUser]' and sPassword ='$passlogin'");
			$rowpass = mssql_num_rows($querypass);
			$rowquerypass = mssql_fetch_array($querypass);
			
		
				if($rowpass == 0)
				{
					$_SESSION['code_errorlogin'] = "Password Fail";
				}else {
				
						$_SESSION['type'] =  $loginquery['fkRole'];
						$_SESSION['project'] =  $loginquery['fkProject'];
						$_SESSION['user'] =  $rowquerypass['sFirstname'];
						$_SESSION['pkUser'] =  $rowquerypass['pkUser'];
						$_SESSION['active'] = 'active';
				
						if($_SESSION['type'] == 1)// admin
								{
										echo "<meta http-equiv='refresh' content='0;URL=admin.php'>";	
													
									}else if ($_SESSION['type'] == 2)//projectsite
									{	
										echo "<meta http-equiv='refresh' content='0;URL=projectsite.php'>";		
									}
									else if ($_SESSION['type'] == 3)//usercentarl
									{	
										echo "<meta http-equiv='refresh' content='0;URL=central.php'>";	
									}
									else if ($_SESSION['type'] == 4)//projectsite
									{	
										echo "<meta http-equiv='refresh' content='0;URL=silde.php'>";	
						}
				
				}
		}
			
		
		

?>